<?php
require_once dirname(__FILE__) . "/../../includes/config.php";
require_once PHP_ROOTPATH.'/classes/database.php';
//récupération des localisations dans la base de données en fonction de la boite et de l'animal sélectionnés
header("Content-Type: text/xml; charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo "<list>";
 
$boite = (isset($_POST["boite"])) ? html_entity_decode($_POST["boite"]) : NULL;
$id_anim = (isset($_POST["id_anim"])) ? html_entity_decode($_POST["id_anim"]) : NULL;

if ($boite && $id_anim) {
    $id_connect=Database::getInstance();
    $query_temp = "SELECT DISTINCT(localisation) FROM Biobanque WHERE nom_boite='".pg_escape_string($boite) ."' AND id_animal=$id_anim 
    ORDER BY localisation";
    $res_query = pg_query($id_connect , $query_temp) or die(pg_last_error());
    while ($back = pg_fetch_assoc($res_query)) {
        echo "<item id=\"" . $back["localisation"] . "\" name=\"" . $back["localisation"] . "\" />\n";
    }
}
 
echo "</list>";


?>
